<template>
 <div class="min-h serveProject bg-wt">
  <SearchForm 
  :searchData="pagination"
  :statusData="statusData"
  @handleSearch="getList"
  @handleReset="handleReset"
  @hanleClear="hanleClear"
  ></SearchForm>
    <!-- 展示列表页面 
    定义属性和方法
    -->
    <TableList
    :data="data"
    :total="total"
    :pagination="pagination"
    @onPageChange="onPageChange"
    ></TableList>
  
    </div>
</template>

<script setup lang="jsx">
import { ref ,onMounted} from 'vue'
//import { ErrorCircleFilledIcon, CheckCircleFilledIcon, CloseCircleFilledIcon } from 'tdesign-icons-vue-next'
//引入搜索框组件
import SearchForm from './components/SearchForm.vue'
import { getProjectList } from '@/api/serve.ts'
  //引入状态枚举
  import {statusData} from '@/utils/commonData'
//引入列表页组件
import TableList from './components/TableList.vue'
const data = ref([])
const total = ref(0)
const hover = ref(false)
const dataLoading = ref(false) // 加载中
/* for (let i = 0; i < total; i++) {
  data.push({
    "id": i + 1,
        "createTime": "2022-01-05 12:00:00",
        "createDay": null,
        "updateTime": "2022-01-05 12:00:00",
        "createBy": "1671403256519078138",
        "updateBy": "1",
        "dataState": null,
        "remark": "备注5",
        "createType": null,
        "creator": null,
        "adminCreator": null,
        "updater": null,
        "name": "项目5",
        "orderNo": 5,
        "unit": "个",
        "price": 180,
        "image": 'https://yjy-slwl-oss.oss-cn-hangzhou.aliyuncs.com/2a6ababd-6f0d-4e07-9dff-ca34123912dc.png',
        "nursingRequirement": "护理要求5",
        "status": 0,
        "count": null
  });
} */

/* const stripe = ref(true);
const bordered = ref(true);
const hover = ref(false);
const tableLayout = ref(false);
const size = ref('medium');
const showHeader = ref(true); */
 




const pagination = ref({
  pageSize: 5,
  pageNum: 1

})
const onPageChange = async (val) => {
  pagination.value.pageNum = val.current
  pagination.value.pageSize = val.pageSize
   getList()
}
onMounted(() => {
getList()
})
//调用接口
const getList = async () => {
  const result = await getProjectList(pagination.value)
  data.value = result.data.records
  total.value = result.data.total
}
//重置搜索框
const handleReset=()=>{
  //重置页码
  /* pagination.value={
    pageSize: 10,
    pageNum: 1
  } */
  delete pagination.value.name
  delete pagination.value.status
  //重新查询列表
  getList();
}
//搜索
const handleSearch=()=>{
  getList();
}
//清空
const handleClear=(val)=>{
  if(val==='name'){
    delete pagination.value.name
  }else{
    delete pagination.value.status
  }
  getList();
}
</script>